package com.yjt.admin.system.controller;


import com.yjt.admin.system.form.RoleMenuForm;
import com.yjt.admin.system.service.RoleMenuService;
import com.yjt.admin.system.vo.MenuVO;
import com.yjt.common.enums.ModulEnum;
import com.yjt.common.enums.OperTypeEnum;
import com.yjt.common.log.annotation.OperLog;
import com.yjt.common.vo.CommonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 角色菜单表 前端控制器
 * </p>
 *
 * @author zzp
 * @since 2021-10-08
 */
@RefreshScope // 支持Nacos的动态刷新功能
@RestController
@RequestMapping("/admin/system/role-menu")
@Api(tags = "角色菜单关系管理")
public class RoleMenuController {


    @Autowired
    private RoleMenuService roleMenuService;


    @GetMapping("/{roleId}")
    @ApiOperation(value = "通过角色id查询菜单信息", notes = "返回JSONObject")
    @ApiImplicitParam(name = "roleId", value = "角色id")
    public CommonResult<List<MenuVO>> getMenuWithRoleId(@PathVariable String roleId) {
        return CommonResult.success(roleMenuService.getMenuWithRoleId(roleId));
    }


    @GetMapping("/list")
    @ApiOperation(value = "查询所有模块菜单信息", notes = "返回JSONObject")
    public CommonResult<Map<String, List<MenuVO>>> listMenu() {
        return CommonResult.success(roleMenuService.getListMenu(), "所有菜单模块信息查询成功");
    }

}
